package gazzera.node.core;

import gazzera.node.core.messages.*;

import java.io.*;


public class TreeDataPumpSource implements DataPumpSource
{
	File[] files;
	int index;

	public TreeDataPumpSource(File f)
	{
		files = f.listFiles();
		index = 0;
	}

	public void init()
	{

	}

	@Override
	public void finished(boolean interrupted)
	{
		System.out.println("finished! " + interrupted);
	}

	@Override
	public Message next() throws Exception
	{
		if (index < files.length)
		{
			File toSend = files[index];

			index++;
			return new Chat(toSend.getAbsolutePath());
		} 
		else
		{
			//throw new RuntimeException("ciao");
			return null;
		}
	}

}
